Example: Retrieve a Decision Report

Example: Retrieve a decision report      

Once a value has been found for an attribute (possibly by investigating a goal), it is useful to be able to explain why the attribute has that particular value.

A decision report is a recursive structure that contains a series of nodes, and explains the series of steps that led to an attribute having a particular value. A simple example follows.

The applicant is eligible for a driver's license because:

The applicant is over 16, because:

The applicant's age is 18, because:

The applicant's date of birth is 27th February 1985, and

The date of application is 14th May 2003

Note:
The bold statements do not appear in a decision report, but are added here for clarity

Each line above would be represented by a DecisionReportNode object.

Each DecisionReportNode may contain other DecisionReportNode objects as children. In the example above, 'The date of application' and 'The applicant's date of birth' are both children of the DecisionReportNode containing 'The applicant's age'.

Retrieving a decision report is simply a matter of calling Attribute.getDecisionReport() for the Attribute whose value needs to be explained. The task of displaying the decision report to the user is more difficult. However, the recursive nature of the DecisionReportNode objects makes it natural to write a recursive method to display the report.

The following code fragments follow on directly from the examples shown under Investigate a Goal, and use a recursive method to display a report for the global attribute 'a5' - click on the appropriate heading to view either the Java or the C# example: